class SimpleButton:
	def __init__(self, p_rect, imges_state_array, parent_screen):
		self.imgs = imges_state_array
		self.img = imges_state_array[0]
		self.screen = parent_screen
		self.rect = p_rect
		self.pos = self.rect.topleft
		self.state = 0
		self.mask = None
	
	def Draw(self):
		self.screen.blit(self.img, self.pos)
		
	def Over(self, pos):
		if self.state == 0:
			if(self.rect.collidepoint(pos)):
				self.img = self.imgs[1]
				self.state = 1;
		elif self.state == 1:
			if not self.rect.collidepoint(pos):
				self.img = self.imgs[0]
				self.state = 0;
				
	def Down(self):
		self.img = self.imgs[2]
		self.state = 2;
	
	def Up(self):
		self.img = self.imgs[0]
		self.state = 0;
		
	def TestDown(self, mouse_pos):
		if self.rect.collidepoint(mouse_pos):
			self.Down()
			return True
			
	def SetMask(self, new_mask):
		self.mask = new_mask
		
	def MaskOver(self, pos):
		if self.state == 0:
			if self.mask.get_at(pos):
				self.state = 1
				return True
		elif self.state == 1:
			if not self.mask.get_at(pos):
				self.state = 0
		return False